package cn.mabach.DTO;

import lombok.Data;
import org.apache.http.HttpStatus;

import java.io.Serializable;


@Data
public class RS<T> implements Serializable {
    private Integer code;
    private String msg;
    private T data;

    public RS() {
    }

    public RS(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public RS(Integer code, String msg, T t) {
        this.code = code;
        this.msg = msg;
        this.data = t;
    }

    public static RS ok(){
        return new RS(HttpStatus.SC_OK,"操作成功");
    }

    public static RS ok(String msg){
        return new RS(HttpStatus.SC_OK,msg);
    }

    public static RS ok(Object object){
        return new RS(HttpStatus.SC_OK,"操作成功",object);
    }

    public static RS ok(String msg,Object object){
        return new RS(HttpStatus.SC_OK,msg,object);
    }

//    成功通用封装
    public static RS ok(Integer code,String msg,Object object){
        return new RS(code,msg,object);
    }




    public static RS error(){
        return new RS(HttpStatus.SC_INTERNAL_SERVER_ERROR,"操作失败");
    }

    public static RS error(String msg){
        return new RS(HttpStatus.SC_INTERNAL_SERVER_ERROR,msg);
    }

    public static RS error(Integer code,String msg){
        return new RS(code,msg);
    }



}
